package com.code.leetcode.offer;

import java.util.Arrays;

/**
 * @author codeDorado
 * @version 1.0
 * @date 2020/8/6 8:53
 */
public class The58_1 {
    public String reverseWords(String s) {
        String[] split = s.trim().split(" ");
        StringBuilder builder = new StringBuilder();
        for (int i = split.length - 1; i >= 0; i--) {
            if ("".equals(split[i])) continue;
            builder.append(split[i]).append(" ");
        }
        return builder.toString().trim();
    }

    public static void main(String[] args) {
        The58_1 the58_1 = new The58_1();
        System.out.println(the58_1.reverseWords("a good   example"));
    }
}
